/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.pitkley.jocreatulary;

import java.util.ArrayList;
import java.util.Random;

/**
 *
 * @author pit
 */
public class Vocable {

    private static final Random r = new Random();
    private boolean required;
    private String type = null;
    private ArrayList<String> nativeWords = new ArrayList<String>();
    private ArrayList<String> translations = new ArrayList<String>();
    private int timesCorrect = 0;

    public void setRequired(boolean pRequired) {
        required = pRequired;
    }

    public boolean getRequired() {
        return required;
    }

    public void setType(String pType) {
        type = pType;
    }

    public String getType() {
        return type;
    }

    public void addNativeWords(String pNativeWord) {
        nativeWords.add(pNativeWord);
    }

    public ArrayList<String> getNativeWords() {
        return nativeWords;
    }

    public String getRandomNativeWord() {
        return nativeWords.get(r.nextInt(nativeWords.size()));
    }

    public boolean verifyNativeWord(String pNativeWord) {
        for (String s : nativeWords) {
            if (s.equalsIgnoreCase(pNativeWord)) {
                return true;
            }
        }
        return false;
    }

    public void addTranslation(String pTranslation) {
        translations.add(pTranslation);
    }

    public ArrayList<String> getTranslations() {
        return translations;
    }

    public String getRandomTranslation() {
        return translations.get(r.nextInt(translations.size()));
    }

    public boolean verifyTranslation(String pTranslation) {
        for (String s : translations) {
            if (s.equalsIgnoreCase(pTranslation)) {
                return true;
            }
        }
        return false;
    }

    public int getTimesCorrect() {
        return timesCorrect;
    }

    public void setTimesCorrect(int pTimesCorrect) {
        timesCorrect = pTimesCorrect;
    }

    public void answer(boolean correct) {
        if (correct) {
            timesCorrect++;
        } else {
            timesCorrect = 0;
        }
    }
}
